package com.lizhangjun.entity;

/**
 * 系统统一响应实体
 * @author 11851
 */
public class Result
{
    /**
     * 响应状态码
     */
    private Integer code;
    /**
     * 返回信息
     */
    private String message;
    /**
     * 返回数据
     */
    private Object data;

    public Result() {
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    /**
     * 请求成功
     * @return result
     */
    public static Result success(){
        return new Result(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage());
    }

    /**
     * 请求成功
     * @param data 数据
     * @return result
     */
    public static Result success(Object data){
        return new Result(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(),data);
    }

    /**
     * 请求成功
     * @param message 返回信息
     * @param data 数据
     * @return result
     */
    public static Result success(String message, Object data){
        return new Result(ResultCode.SUCCESS.getCode(), message, data);
    }

    /**
     * 请求失败
     * @return result
     */
    public static Result fail(){
        return new Result(ResultCode.ERROR.getCode(), ResultCode.ERROR.getMessage());
    }

    /**
     * 请求失败
     * @param message 返回信息
     * @return result
     */
    public static Result fail(String message){
        return new Result(ResultCode.ERROR.getCode(), message);
    }

    /**
     * 请求失败
     * @param message 返回信息
     * @param data 返回数据
     * @return result
     */
    public static Result fail(String message, Object data){
        return new Result(ResultCode.ERROR.getCode(), message, data);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}


